package com.alesj.newsfeed.web.object;

import java.util.List;

import com.alesj.newsfeed.data.ReporterContact;
import com.generalynx.ecos.page.SloAlphaPageScroll;
import org.hibernate.transform.ResultTransformer;

/**
 * @author Ales Justin
 */
public class MediaPageScroll extends SloAlphaPageScroll {

    public ResultTransformer transformer() {
        return new MediaTransformer();
    }

    private class MediaTransformer implements ResultTransformer {

        public Object transformTuple(Object[] tuple, String[] aliases) {
            return tuple[tuple.length - 1];
        }

        public List transformList(List collection) {
            for(Object c : collection) {
                if (c instanceof ReporterContact) {
                    ReporterContact rc = (ReporterContact)c;
                    rc.setAdeLabelName(rc.getMedia());
                }
            }
            return collection;
        }
    }
}
